package com.dyz.leetcode._14_binarySearchTree;

import com.dyz.leetcode.TreeNode;

public class _226_invertTree {
    public TreeNode invertTree(TreeNode root) {
       return postOrder(root);
    }

    private TreeNode postOrder(TreeNode node){
        if(node==null){return null;}
        if(node.left==null && node.right==null){return node;}

        TreeNode left = postOrder(node.left);
        TreeNode right = postOrder(node.right);

        node.left = right;
        node.right = left;
        return node;
    }

}
